<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form id="f1" th:action="@{/cate}" th:object="${categroy}" method="post">
        <h1 th:if="${categroy.id == null}">新增条目</h1>
        <div th:if="${categroy.id != null}">
            <h1>修改条目</h1>
            <input type="hidden" th:field="*{id}">
            <input type="hidden" name="_method" value="PUT">
        </div>
        <p>分类名：<input type="text" th:field="*{name}" ></p>
        <label style="color:red" th:if="${#fields.hasErrors('name')}" th:errors="*{name}">名称不为空</label>
        <p>上级分类id：<input type="text" th:field="*{pid}"></p>
        <p>分类说明：<input type="text" th:field="*{remark}"></p>
        <button>保存</button>
    </form>
</body>
</html>